
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@page import="java.sql.*"%>
<%@page import="com.mysql.*"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.*" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

	
<!-- <link rel="stylesheet" href="../../css/style.css"> -->
<link rel="stylesheet" href="resources/mytheme/css/normalize.css">
<link rel="stylesheet" href="resources/mytheme/css/style.css">
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css"
	href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css">

<!-- jQuery -->
<script type="text/javascript" charset="utf8"
	src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<!--  sortable -->
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

<!-- DataTables -->
<script type="text/javascript" charset="utf8"
	src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		
	});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Administration - Reports</title>
<link rel="stylsheet" href="css/style.css">
<script>
  $(function() {
    $( "#sortable" ).sortable();
    $( "#sortable" ).disableSelection();
    
  });
  </script>

</head>
<body>
<center>
<div id=header>

	<div id="logo">
		<img src="resources/mytheme/img/Logo.png" alt="RentFlix">
	</div>
	
	<div id="searchNav">
		<form name="inputForm" method="get">
			<input class="searchBox" type="text" name="searchBox" placeholder="Search for Movies..." onkeyup="fastSearch()">
			<input class="searchButton" type="submit" value="Search">
			<br>
			<!-- <input class="checkbox" type="checkbox" name="desc" value="show">Show Description -->
		</form>
	</div>
	
	<div id="navBar">
		<ul>
		    <li><a href="/MovieProject/browse">Movies</a></li>
		    <li><a href="/MovieProject/browse?genre=Family&rating=&decade=">Kids</a></li>
		    <li><a href="/MovieProject/viewqueue">Queue</a></li>
		</ul>
	</div>
	
	<div id="loginBar">
		<ul>
				<li><div id="signoutform"><form action="signout" method="post" name="loutform"><input class="lastlink" type="submit" value="Sign Out" style="text-transform:capitalize;"></form></div></li>
			<li><a class="firstlink"href="/MovieProject/MyAccount">My Account</a></li>
			
		</ul>
	</div>
	
</div>
<div id="body">
<%
	ArrayList<String> al = new ArrayList<String>();
	
    try{
    	int u = (Integer)request.getSession().getAttribute("uName");
    	
    	int i = 3; // This should be the user id
    	
    	
  	
//Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = 
         DriverManager.getConnection
            ("jdbc:mysql://localhost:3306/moviedatabase","dbuser","dbpassword");
       Statement statement = connection.createStatement() ;
     	ResultSet rs = statement.executeQuery("select * from movies JOIN queue ON movies.MovieID = queue.MovieID JOIN users ON users._z4 = queue.UserID WHERE queue.UserID ="+u+";") ;  
     
      
%>
<div id="queue">
<br><br><br><br>
	<h1>Your Queue</h1>
	Click and drag to rearrange your queue.
	<br>
	<form action="/MovieProject/cart">
    <input type="submit" value="Order Movies">
</form>
	<br>
	<br />
	<table id="q" class="display">
		<thead>
			<tr>
				<th></th>
				<th>Name</th>
				<th>Cast</th>
				<th>Genre</th>
			</tr>
		</thead>
		<tbody id="sortable">
				<%   
					while(rs.next()){  %>
					<tr>
					 <td width="70">  <a href="/MovieProject/movie?searchBox=<%= rs.getString(2)%>" >
					<img src="<%= rs.getString(8)%>" border="0" style="border:none;max-width:40px;"  /></a>
					</td>
					<td width="250"><%= rs.getString(2)%></td>
					<td width="150"><%= rs.getString(3)%></td>
					<td width="150"><%= rs.getString(4)%></td>
					</tr>
	        	<% } %>
				
					
				
			
		</tbody>
	</table>
	</div>
	<center>
       <table><tr >
        <%   
        while(rs.next()){  %>
         <tr>
          <td>  <a href="/MovieProject/movie?searchBox=<%= rs.getString(2)%>" >
				<img src="<%= rs.getString(8)%>" border="0" style="border:none;max-width:100%;"  /></a>
          </td>
         	</tr>
        <% } %>
        </tr></table>
        </center>
	
	
	
<%
//**Should I input the codes here?**
          
        }
        catch(Exception e)
        {
             out.println("wrong entry"+e);
        }
%>
</div>
<br><br><br><br>
<div id="footer">
	<div id="foota2">
		<p>Get Help</p>
		<ul>
		  <li><a href="#">FAQ</a></li>
		  <li><a href="#">Help Center</a></li>
		  <li><a href="#">Account</a></li>
		  <li><a href="#">Questions</a></li>
		</ul>
	</div>

	<div id="footb"><p>Our Company</p>
	
		<ul>
		  <li><a href="#">About us </a></li>
		  <li><a href="#">Reviews  </a></li>
		  <li><a href="#">Jobs  </a></li>
		  <li><a href="#">Terms of Use</a></li>
		</ul>
	</div>
	
	<div id="footc"><p>Getting Started</p>
		<ul>
		  <li><a href="#">Free Trail Offer Details  </a></li>
		  <li><a href="#"> Redeem Your Gift</a></li>
		</ul>
	</div>
</div>
</center>
</body>
</html>